package lab.bmp;

import java.io.Serializable;

/**
 *
 * @author Smike
 */
public abstract class AbstractPK<T extends Serializable> implements Serializable {
    
    T id;

    public AbstractPK(T id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
    
    public T getId() {
        return id;
    }

    @Override
    public String toString() {
        return getClass().getName() + "." + id.toString();
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj.getClass().equals(getClass())) {
            return hashCode() == obj.hashCode();
        }
        return false;
    }
    
}
